<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /**
     * str.slice(start,end) 截取字符串
     * start索引位置的字符是包含的
     * end索引位置的字符是不包含的
    */
    var str = "nice to meet you";
    var childStr = str.slice(0,7);
    var childStr = str.slice(0,16);
    console.log(childStr);
    //str.slice(start,)
    //截取结果为从截取起始到整个字符串结束
    var str2 = str.slice(1,);
    console.log(str2);
    //设定负值，表示从右向左，确定索引位置
    var str3 = str.slice(-8);
    console.log(str3);
</script>
</html>